import babel from '@rollup/plugin-babel';
import vuePlugin from 'rollup-plugin-vue';
import json from 'rollup-plugin-json';
const es = {
  input: 'src/entry.js',
  output: {
    file: 'dist/index.bundle.js',
    name: 'MyFirstPlugin',// 插件调用名称
    format: 'es',
    globals: {
      vue: 'Vue',
    },
  },
  external: ['vue'],
  plugins: [
    json(),
    babel(),
    vuePlugin({
      css: true,
    }),
  ],
};

const iife = {
  input: 'src/entry.js',
  output: {
    file: 'dist/index.js',
    name: 'MyFirstPlugin',// 插件调用名称
    format: 'iife',
    globals: {
      vue: 'Vue',
    },
  },
  external: ['vue'],
  plugins: [
    json(),
    babel(),
    vuePlugin({
      css: true,
    }),
  ],
};

import { terser } from 'rollup-plugin-terser';
const minEs = {
  input: 'src/entry.js',
  external: ['vue'],
  output: {
    file: 'dist/index.min.js',
    name: 'MyFirstPlugin',// 插件调用名称
    format: 'umd',
  },
  plugins: [
    json(),
    babel(),
    vuePlugin({
      css: true,
    }),
    terser(),
  ],
};

const cjs = {
  input: 'src/entry.js',
  external: ['vue'],
  output: {
    file: 'dist/index.cjs.js',
    name: 'MyFirstPlugin',// 插件调用名称
    format: 'cjs',
    exports:'default'
  },
  plugins: [
    json(),
    babel(),
    vuePlugin({
      css: true,
    }),
  ],
};

export default [es, iife, minEs, cjs];
